package com.fastloan.jn.mgt.customermanager.level.service.impl;

import com.fastloan.jn.common.BasicServiceImpl;
import com.fastloan.jn.utils.other.ObjUtil;
import com.fastloan.jn.mgt.customermanager.level.service.JnManagerQuotaSettingService;
import com.fastloan.jn.mgt.customermanager.level.model.JnManagerQuotaSetting;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author gelon
 *         createTime 2017/10/31
 */
@org.springframework.stereotype.Service
public class JnManagerQuotaSettingServiceImpl extends BasicServiceImpl<JnManagerQuotaSetting> implements JnManagerQuotaSettingService {
    @org.springframework.beans.factory.annotation.Autowired
    private com.fastloan.jn.mgt.customermanager.level.dao.JnManagerQuotaSettingMapper JnManagerQuotaSettingMapper;

    @Override
    @Transactional
    public void saveUpdate(List<JnManagerQuotaSetting> managerQuotaSettings) {
        managerQuotaSettings.forEach(this::saveUpdateEntity);
    }

    private void saveUpdateEntity(JnManagerQuotaSetting jnManagerQuotaSetting) {
        if(ObjUtil.isEmpty(jnManagerQuotaSetting.getId())){
            insertSelective(jnManagerQuotaSetting);
        }else{
            updateByPrimaryKey(jnManagerQuotaSetting);
        }

    }


}
